package com.spark.lola.entity.pur;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.spark.lola.constant.SupReturnStatus;
import com.spark.lola.support.common.entity.ShiroUser;
import com.spark.lola.support.mybatis.entity.BaseModel;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 退货单
 * </p>
 *
 * @author dengyejun
 * @since 2020-05-18
 */
@TableName("pur_return_order_info")
@ApiModel(value="ReturnOrderInfo对象", description="退货单")
public class ReturnOrderInfo extends BaseModel implements Serializable {
    private static final long serialVersionUID = 1L;

    public ReturnOrderInfo() {
    }

    public ReturnOrderInfo(OrderInfo orderInfo) {
        this.no = orderInfo.getNo();
        this.orderId = orderInfo.getId();
        this.consigneeId = orderInfo.getConsigneeId();
        this.supplierId = orderInfo.getSupplierId();
        this.consignee = orderInfo.getConsignee();
        this.orderLocation = orderInfo.getStartLocation();
        List<Long> productIds = new ArrayList<>();
        List<String> productNames = new ArrayList<>();
        List<ReturnOrderProduct> details =new ArrayList<>();
        orderInfo.getDetails().forEach(o -> {
            productIds.add(o.getProductId());
            productNames.add(o.getName()+"/"+o.getPackages()+"/"+o.getQuantity());
            ReturnOrderProduct detail =new ReturnOrderProduct(o);
            details.add(detail);
        });
        this.details = details;
    }

    @ApiModelProperty(value = "退货单")
    private String no;

    @ApiModelProperty(value = "采购单Id")
    private Long orderId;

    @ApiModelProperty(value = "接货员Id")
    private Long consigneeId;

    @ApiModelProperty(value = "供应商Id")
    private Long supplierId;

    @ApiModelProperty(value = "供应商")
    @TableField(exist = false)
    private String supplierName;

    @ApiModelProperty(value = "接货员")
    @TableField(exist = false)
    private ShiroUser consignee;

    @ApiModelProperty(value = "退货量")
    private BigDecimal quantity=BigDecimal.ZERO;

    @ApiModelProperty(value = "货款")
    private BigDecimal totalAmount=BigDecimal.ZERO;

    @ApiModelProperty(value = "打包数")
    private Integer packages=0;

    @ApiModelProperty(value = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @ApiModelProperty(value = "完成时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField(fill = FieldFill.INSERT)
    private String creator;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updator;

    private String productIds;

    private String productNames;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "状态 0-待审核 1-已发货 2-已完成")
    private Integer status = SupReturnStatus.WAIT;

    @TableField(exist = false)
    private List<ReturnOrderProduct> details =new ArrayList<>();

    @ApiModelProperty(value = "退货地址")
    @TableField(exist = false)
    private OrderLocation orderLocation;

    public Long getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Long supplierId) {
        this.supplierId = supplierId;
    }

    public String getSupplierName() {
        return supplierName;
    }

    public void setSupplierName(String supplierName) {
        this.supplierName = supplierName;
    }

    public Long getConsigneeId() {
        return consigneeId;
    }

    public void setConsigneeId(Long consigneeId) {
        this.consigneeId = consigneeId;
    }

    public ShiroUser getConsignee() {
        return consignee;
    }

    public void setConsignee(ShiroUser consignee) {
        this.consignee = consignee;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public OrderLocation getOrderLocation() {
        return orderLocation;
    }

    public void setOrderLocation(OrderLocation orderLocation) {
        this.orderLocation = orderLocation;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public BigDecimal getQuantity() {
        return quantity;
    }

    public void setQuantity(BigDecimal quantity) {
        this.quantity = quantity;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public Integer getPackages() {
        return packages;
    }

    public void setPackages(Integer packages) {
        this.packages = packages;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getUpdator() {
        return updator;
    }

    public void setUpdator(String updator) {
        this.updator = updator;
    }

    public String getProductIds() {
        return productIds;
    }

    public void setProductIds(String productIds) {
        this.productIds = productIds;
    }

    public String getProductNames() {
        return productNames;
    }

    public void setProductNames(String productNames) {
        this.productNames = productNames;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public List<ReturnOrderProduct> getDetails() {
        return details;
    }

    public void setDetails(List<ReturnOrderProduct> details) {
        this.details = details;
    }

    @Override
    public String toString() {
        return "ReturnOrderInfo{" +
                "no=" + no +
                ", orderId=" + orderId +
                ", quantity=" + quantity +
                ", totalAmount=" + totalAmount +
                ", packages=" + packages +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", creator=" + creator +
                ", updator=" + updator +
                ", productIds=" + productIds +
                ", productNames=" + productNames +
                ", status=" + status +
                "}";
    }
}
